package com.szml.service.impl;

import com.szml.entity.User;
import com.szml.mapper.UserMapper;
import com.szml.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    /**
     * 用户登录
     * @param user
     * @return
     */
    @Override
    @Transactional
    public User login(User user) {
        //根据用户名、密码查询数据库
        User u = userMapper.login(user);
        if(u != null){
            //成功
            return u;
        }
        //失败
        throw new RuntimeException("登录失败");
    }
}
